<template>
  <div class="address">
    <div class="header">
      <span class="title">收货地址</span>
    </div>
    <div class="reaceaddress">
      <ul>
        <li class="place" v-for="item in list" :key="item.id">
          <div @click="choose(item)">
          <div class="placetop">
            <span class="name">{{item.receiveName}}</span>
            <span class="phonenum">{{item.receivePhone}}</span>
          </div>
          <div class="detailplace">{{item.receiveAddr}}</div>
          </div>
          <div class="icons">默</div>
          <div class="right" @click="go(item)">编辑</div>
        </li>
      </ul>
      <div class="newaddress" @click="goto()">
        新增收获地址
        <img :src="images5" class="images5">
      </div>
    </div>
  </div>
</template>

<script>
import pic4 from "../../icons/left2.png";
import pic5 from "../../icons/right.png";
import * as api from "../../request/api.js";
export default {
  name: "Address",
  data() {
    return {
      images4: pic4,
      images5: pic5,
      list: ""
    };
  },
  created() {
    this.$http
      .post(api.ADDRESSLIST, {
        data: {
          pageNo: 1,
          pageSize: 10
        }
      })
      .then(resp => {
        console.log(resp);
        this.list = resp.data.data;
      })
      .catch(resp => {});
  },
  methods: {
    go(item) {
      this.$router.push({
        path: "/modifyplaces",
        query: {
          id: item.id,
          receiveName: item.receiveName,
          receivePhone: item.receivePhone,
          receiveAddr: item.receiveAddr,
          totaleprice:this.$route.query.totaleprice
        }
      });
    },
    goto() {
      this.$router.push({ path: "./chooseplaces",
      query:{
        totaleprice:this.$route.query.totaleprice
      } });
    },
    choose(item) {
      let totaleprice = this.$route.query.totaleprice;
      // let dealModeName= JSON.parse(this.$route.query.dealModeName)
      let toatlprice=this.$route.query.toatlprice
      console.log(totaleprice)
      this.$router.push({
        path: "/payment",
        query: {
          id: item.id,
          receiveName: item.receiveName,
          receivePhone: item.receivePhone,
          receiveAddr: item.receiveAddr,
          totaleprice
        }
      });
      if(this.$route.query.totaleprice==null){
              this.$router.push({
        path: "/payment",
        query: {
          id: item.id,
          receiveName: item.receiveName,
          receivePhone: item.receivePhone,
          receiveAddr: item.receiveAddr,
          // dealModeName,
          toatlprice,
        }
      });
      }
    }

  }
};
</script>

<style lang="less" scoped>
@import "../../less/address.less";
</style>
